﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AuditSample
{
    public static class DictHelper
    {
        public static DateTime GetDate(this IDictionary<string, object> data, string key)
        {
            if (data.ContainsKey(key) && data[key] != null)
                return Convert.ToDateTime(data[key], CultureInfo.InvariantCulture);
            else
                return DateTime.MaxValue;
        }

        public static string GetString(this IDictionary<string, object> data, string key)
        {
            if (data.ContainsKey(key) && data[key] != null)
            {
                return data[key].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
    }
}
